﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TTEditor
{

    //这个基类表示可以被选中的物体
    public interface ITTSelectObject
    {
        string Name
        {
            get;
        }
    }

    public static class Selector
    {
        public static void ClearSelectOnAllSlot()
        {
            selectObjects.Clear();
        }
        public static void ClearSelect(int slot)
        {
            if (selectObjects.ContainsKey(slot))
            {
                selectObjects[slot].Clear();
            }
        }
        /// <summary>
        /// 选择物体
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="objs"></param>
        public static void Select(int slot, params ITTSelectObject[] objs)
        {
            if (selectObjects.ContainsKey(slot) == false)
            {
                selectObjects[slot] = new List<ITTSelectObject>();
            }
            List<ITTSelectObject> list = selectObjects[slot];
            list.Clear();
            list.AddRange(objs);
        }
        /// <summary>
        /// 添加到当前选择物体
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="objects"></param>
        public static void SelectAdd(int slot, params ITTSelectObject[] objs)
        {
            if (selectObjects.ContainsKey(slot) == false)
            {
                selectObjects[slot] = new List<ITTSelectObject>();
            }
            List<ITTSelectObject> list = selectObjects[slot];
            list.AddRange(objs);
        }
        static Dictionary<int, List<ITTSelectObject>> selectObjects = new Dictionary<int, List<ITTSelectObject>>();
        public static IList<ITTSelectObject> GetSelected(int slot)
        {
            if (selectObjects.ContainsKey(slot) == false)
            {
                return null;
            }
            return selectObjects[slot];
        }
    }
}
